package com.yicong.ants.scenic.adapter

import android.view.View
import com.blankj.utilcode.util.TimeUtils
import com.chad.library.adapter.base.BaseQuickAdapter
import com.x.livesdk.BaseDataBindingHolder
import com.yicong.ants.R
import com.yicong.ants.databinding.ScenicDetailPriceDayListItemBinding
import com.yicong.ants.scenic.data.PriceDay

class CalendarAdapter(priceDays: ArrayList<PriceDay>) :
    BaseQuickAdapter<PriceDay, BaseDataBindingHolder<ScenicDetailPriceDayListItemBinding>>(
        R.layout.scenic_detail_price_day_list_item,
        priceDays
    ) {

    public var selectedDay: PriceDay? = null
    override fun convert(
        holder: BaseDataBindingHolder<ScenicDetailPriceDayListItemBinding>,
        item: PriceDay
    ) {
        holder.dataBinding?.data = item
        holder.dataBinding?.root?.visibility = View.VISIBLE
        if (item.date.isNullOrBlank()) {
            holder.dataBinding?.root?.visibility = View.INVISIBLE
        }
        holder.dataBinding?.title?.text = TimeUtils.date2String(item.dateObj, "d");
        holder.dataBinding?.title?.isEnabled = !item.settlePriceYbt.isNullOrBlank()
        holder.dataBinding?.root?.isSelected = item == selectedDay
    }
}